package org.thanos.demo.service.menu;

import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.lang.util.Assert;
import org.springframework.stereotype.Service;
import org.thanos.demo.entity.SysMenu;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service("sysMenuService")
public class SysMenuServiceImpl implements SysMenuService {

    @Override
    public List<String> selectAllPermits(List<Integer> menuIds) {
        Assert.isTrue(CollectionUtils.isNotEmpty(menuIds));
        return menuIds.stream().map(menuId -> SysMenu.data().stream().filter(sysMenu -> sysMenu.getId().equals(menuId)).map(SysMenu::getOperation).findAny().orElse(null)).filter(Objects::nonNull).collect(Collectors.toList());
    }
}
